package com.test.springboot3.springboot3testdemo1.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebInitParam;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2024/8/2-下午12:31
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@WebServlet(
    name = "javaServlet",
    urlPatterns = "/javaServlet",
    asyncSupported = true,
    initParams = {
      @WebInitParam(name = "name", value = "javaServlet"),
      @WebInitParam(name = "sex", value = "male")
    })
public class JavaServlet extends HttpServlet {
  /**
   * @param req
   * @param resp
   * @throws ServletException
   * @throws IOException
   */
  @Override
  protected void service(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    final String name = getServletConfig().getInitParameter("name");
    final String sex = getServletConfig().getInitParameter("sex");

    resp.getOutputStream().println("name is " + name);
    resp.getOutputStream().println("sex is " + sex);
  }
}
